<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>编辑社保</span><?php include "../public/sub.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">人员姓名</label>
                        <div class="layui-input-block">
                            <input type="text" id="name" readonly placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>社保状态</label>
                        <div class="layui-input-block">
                            <div id="social"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">参保地</label>
                        <div class="layui-input-block" style="z-index: 1;">
                            <input type="text" name="socialareas" id="socialareas" placeholder="请选择" readonly clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">参保开始月份</label>
                        <div class="layui-input-block">
                            <input type="text" name="socstartdt" id="socstartdt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ym">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">参保结束月份</label>
                        <div class="layui-input-block">
                            <input type="text" name="socenddt" id="socenddt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ym">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">参保说明</label>
                        <div class="layui-input-block">
                            <textarea id="social_explain" name="social_explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;
    layui.use(['laytp', 'form'], function() {
        var form = layui.form;
        render_input_attr();


        facade.ajax({type: 'get', url: ask_cert_person_editsocial, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#name").val(data.name);
                $("#socstartdt").val(data.socstartdt);
                $("#socenddt").val(data.socenddt);
                $("#social_explain").val(data.social_explain);

                $("#socialareas").val(data.socialareas);
                load_areas('socialareas', res.data.areas, 2);

                xmselect_dan('social', res.data.social, data.social, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#social").find('xm-select').removeClass('error');
                    }else{
                        $("#social").find('xm-select').addClass('error');
                    }
                });

                render_from();
            }
        });

        form.on('submit(add)', function(data){
            var validRes = true;
            if(!data.field.social){
                $("#social").find('xm-select').addClass('error');
                validRes = false;
            }else{
                $("#social").find('xm-select').removeClass('error');
            }
            if(!validRes){return false;}

            data.field.id = param_id;
            facade.ajax({url: ask_cert_person_editsocial, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });

</script>
</body>
</html>
